Bar code generation scanning, and display method, apparatus, storage medium, and electronic device

ABSTRACT

This application discloses method, an apparatus, a storage medium, and an electronic device for bar code generation and display. The method includes: obtaining a target code by compiling a source code, the target code being self-contained executable code comprising target computer readable instructions and comprising logic functions, wherein the target computer readable instructions are executable by a processor; and generating a target bar code embedded with the target code by encoding the target code, wherein the target code comprises at least one of the following logical functions: a first logical function for allowing a scanning device with a read permission to run the target code, a second logical function for allowing the target code to be run within a validity period, and a third logical function for calling and configuring target hardware in the scanning device to execute a target operation.

RELATED APPLICATION

This application is a continuation application of U.S. application Ser.No. 16/993,993, filed on Aug. 14, 2020, which is a continuationapplication of the International PCT Application No. PCT/CN2019/082595,filed with the China National Intellectual Property Administration, PRCon Apr. 15, 2019 which claims priority to Chinese Patent Application No.201810427253.5, entitled “BAR CODE DISPLAY METHOD, BAR CODE DISPLAYAPPARATUS, STORAGE MEDIUM, AND ELECTRONIC DEVICE” and filed with theChina National Intellectual Property Administration, PRC on May 7, 2018,which are incorporated herein by reference in their entireties.

FIELD OF THE TECHNOLOGY

This application relates to the field of computer and informationtechnologies, and specifically, to the bar code generating, scanning,and display.

BACKGROUND OF THE DISCLOSURE

At present, bar codes have been widely used in different scenarios. Forexample, a terminal may directly display static information carriedtherein by scanning a bar code, and the static information is reflectedby numerical data, text description, or the like.

The static information displayed by the terminal is often numerical dataor text description in a static form. For example, when the bar codecarries a URL link, the terminal scans the bar code through a built-inapplication. After the scanning, a to-be-accessed URL link is displayed.The terminal then needs to follow the URL link through the applicationto obtain corresponding content information triggered by humaninteraction. Therefore, the content information corresponding to thepage link cannot be displayed automatically by just scanning the QRcode. That is, in the bar code display method provided in the relatedart, there is a problem that information carried in a bar code is staticand relatively simple, and subsequent user action needs to be taken toretrieve full information.

For the foregoing problem, no effective solutions have been put forwardso far.

SUMMARY

Embodiments of this application provide a method, an apparatus, astorage medium, and an electronic device for bar code generating,scanning, and display, to resolve at least the technical problem in therelated art that information carried in a bar code is relatively simple.

According to an aspect of the embodiments of this application, a barcode generating and display method applied to a terminal is provided,including: obtaining a programmable bar code encoding request;generating a target programmable bar code in response to theprogrammable bar code encoding request, the target programmable bar codebeing a bar code obtained by encoding target code, and the target codebeing used for executing a target logical function; and displaying theforegoing target programmable bar code.

According to another aspect of the embodiments of this application, abar code scanning method applied to a terminal is further provided,including: scanning a target programmable bar code to obtain targetcode, the target programmable bar code being a bar code obtained byencoding the target code, and the target code being executable binarycode or source code used for executing a target logical function;running the foregoing target code to execute the foregoing targetlogical function; and displaying a result obtained by executing theforegoing target logical function.

According to another aspect of the embodiments of this application, abar code generating and display apparatus is further provided,including: an obtaining unit, configured to obtain a programmable barcode encoding request; a generating unit, configured to generate atarget programmable bar code in response to the foregoing programmablebar code encoding request, the target programmable bar code being a barcode obtained by encoding target code, and the target code being usedfor executing a target logical function; and a display unit, configuredto display the foregoing target programmable bar code.

According to another aspect of the embodiments of this application, abar code scanning apparatus applied is further provided, including: ascanning unit, configured to scan a target programmable bar code toobtain target code, the target programmable bar code being a bar codeobtained by encoding the foregoing target code, and the target codebeing used for executing a target logical function; a running unit,configured to run the foregoing target code to execute the targetlogical function; and a display unit, configured to display a resultobtained by executing the foregoing target logical function.

According to still another aspect of the embodiments of thisapplication, a storage medium is further provided, the storage mediumstoring a computer program, the computer program being configured toperform, during running, the foregoing method.

According to still another aspect of the embodiments of thisapplication, an electronic device is further provided, including amemory, a processor, and a computer program that is stored on the memoryand that can be run on the processor, the processor being configured toperform, through the computer program, the foregoing method.

In the embodiments of this application, a displayed programmable barcode is obtained by encoding target code, that is, information carriedin the programmable bar code is the target code. Because the target codesupports logical judgments and algorithms, the target code can implementcorresponding logical functions, and expand the range of informationcarried in a bar code, so that the programmable bar code is applicableto more complex scenarios and has more abundant applications. Forexample, the programmable bar code may carry software applications whichmay be executed once decoded. Therefore, the embodiments of thisapplication resolve the technical problem in the related art thatinformation carried in a bar code is static and relatively simple.

BRIEF DESCRIPTION OF THE DRAWINGS

The accompanying drawings described herein are used for providingfurther understanding for this application, and constitute a part ofthis application. Exemplary embodiments of this application anddescriptions thereof are used for explaining this application and do notconstitute an improper limitation to this application. In theaccompanying drawings:

FIG. 1 is a schematic diagram of an exemplary environment of an optionalbar code display method according to an embodiment of this application.

FIG. 2 is a schematic flowchart of an optional bar code display methodaccording to an embodiment of this application.

FIG. 3 is a schematic diagram of encoding an optional QR code accordingto an embodiment of this application.

FIG. 4 is a schematic diagram of obtaining optional target codeaccording to an embodiment of this application.

FIG. 5 is a schematic diagram of an optional programmable QR codedisplay method according to an embodiment of this application.

FIG. 6 is a schematic diagram of optional instance code according to anembodiment of this application.

FIG. 7 is a schematic flowchart of another optional bar code displaymethod according to an embodiment of this application.

FIG. 8 is a schematic diagram of decoding an optional QR code accordingto an embodiment of this application.

FIG. 9 is a schematic diagram of encoding and decoding an optionalprogrammable QR code according to an embodiment of this application.

FIG. 10 is a schematic diagram of an optional programmable QR codeaccording to an embodiment of this application.

FIG. 11 is a schematic diagram of code obtained by converting optionalinstance code through a virtual machine according to an embodiment ofthis application;

FIG. 12 is a schematic structural diagram of an optional bar codedisplay apparatus according to an embodiment of this application.

FIG. 13 is a schematic structural diagram of another optional bar codedisplay apparatus according to an embodiment of this application.

FIG. 14 is a schematic structural diagram of an optional electronicdevice according to an embodiment of this application.

DESCRIPTION OF EMBODIMENTS

To make a person skilled in the related art better understand solutionsof this application, the following clearly and completely describes thetechnical solutions in embodiments of this application with reference tothe accompanying drawings in the embodiments of this application.Apparently, the described embodiments are merely some rather than all ofthe embodiments of this application. All other embodiments obtained by aperson skilled in the art based on the embodiments of this applicationwithout creative efforts shall fall within the protection scope of thisapplication.

In the specification, claims, and the foregoing accompanying drawings ofthis application, the terms “first”, “second”, and so on are intended todistinguish between similar objects rather than indicating a specificorder. It is to be understood that the data termed in such a way areinterchangeable in proper circumstances, so that the embodiments of thisapplication described herein can be implemented in orders except theorder illustrated or described herein. In addition, the terms “include”,“comprise” and any other variants are intended to cover thenon-exclusive inclusion. For example, a process, method, system,product, or device that includes a series of steps or units is notnecessarily limited to those expressly listed steps or units, but mayinclude other steps or units not expressly listed or inherent to such aprocess, method, product, or device.

According to an aspect of the embodiments of this application, a barcode display method is provided. In the embodiments of this application,a programmable bar code is a bar code that can be obtained throughprogramming. The bar code may be a graphical identifier in which aplurality of black bars and blanks having different widths are arrangedaccording to specific encoding rules to express a group of information.For example, the bar code may be specifically a bar shaped code or a QRcode.

Optionally, in an optional implementation, the foregoing bar codedisplay method may be applied to, but not limited to, an exemplaryenvironment shown in FIG. 1 . As shown in FIG. 1 , description is madeby using a QR code. A terminal includes a computer 102 and a mobileterminal 104. The computer 102 may obtain a programmable QR codeencoding request through a server 106 or a network. After receiving therequest, the computer 102 encodes target code in response to the requestand obtains a target programmable QR code carrying the target code, thetarget code being used for executing a target logical function, and thenthe computer 102 displays the target programmable QR code on a displayinterface. The mobile terminal 104 may scan the target programmable QRcode through its own application, to obtain the target code and run thetarget code, to implement a target logical function corresponding to thetarget code, and display, on the mobile terminal 104, a result obtainedby executing the target logical function.

The programmable bar code in the embodiments of this application is sucha technology that by using the existing bar code encoding technology toencode target code. The target code may be binary code (also referred toas byte code in this disclosure) compiled from source code using anon-proprietary or customized, proprietary programming language and thecorresponding compiler. The target code may also be source code using anon-proprietary or customized, proprietary programming language. Thetarget code is encoded into a programmable bar code to obtain acorresponding programmable bar code. During bar code scanning, thetarget code is decoded and retrieved using a corresponding programmablebar code decoding program. Then the target code is run, for example, inthe target operating system directly or through a built-in dedicatedvirtual machine to implement the corresponding logical function.Furthermore, in some embodiments, the target operating system and thededicated virtual machine may be proprietary and is customized toexecute the target code. As such, the target code may not be able to runin other environment. It is to be understood that information carried orembedded in such a programmable bar code is the target code which isexecutable binary code or source code and is different from static textinformation carried in a conventional bar code. Because the target codeimplements logical judgments and algorithms, the target code canimplement corresponding logical functions, and expand the range ofinformation carried in a bar code, so that the programmable bar code isapplicable to more complex scenarios and has more abundant applications.Therefore, the embodiments of this application resolve the technicalproblem in the related art that information carried in a bar code isrelatively simple.

The foregoing terminal to which the embodiments of this application areapplied may be a tablet computer, a notebook computer, a desktop PC, orthe like, or a mobile terminal (mobile phone). The foregoing network mayinclude, but is not limited to a wireless network or a wired network.The wireless network includes: Bluetooth, Wi-Fi, and another networkimplementing wireless communication. The foregoing wired network mayinclude, but is not limited to, a wide area network, a metropolitan areanetwork, and a local area network. The foregoing server may be used fordata calculation and storage, such as a notebook computer or a PC.

According to an aspect of the embodiments of this application, a barcode display method is provided. As shown in FIG. 2 , the foregoing barcode display method may include the following steps:

S202: Obtain a programmable bar code encoding request.

S204: Generate a target programmable bar code in response to theprogrammable bar code encoding request, the target programmable bar codebeing a bar code obtained by encoding target code, and the target codebeing used for executing a target logical function.

S206: Display the target programmable bar code.

The foregoing programmable bar code may be applied to locationpositioning. For example, the target code may carry information forcalling and engaging corresponding positioning hardware. In oneembodiment, the programmable bar code carrying the target code isgenerated and printed on a ticket. When a device scan the programmablebar code, the target code may be retrieved from the programmable barcode. Upon executing the target code by the device, the positioninghardware within the device is identified, called and engaged, to obtainthe position of the device. As another example, the foregoingprogrammable bar code may be applied to a ticket (such as a trainticket, a movie ticket, or an attraction ticket). For example, personalinformation on a ticket is carried in target code, and a programmablebar code carrying the target code is printed on the ticket, so thatcontent carried in the programmable bar code may be target code forretrieving personal information when executed on the device. Theforegoing description is only two examples and this embodiment does notimpose any limitation on this.

A programmable bar code is obtained by encoding the target code, thatis, information carried in the programmable bar code is the target code.Because the target code has logical judgments and algorithms, the targetcode can implement various logical functions, and greatly expand therange of information carried in a bar code, so that the programmable barcode is applicable to more complex scenarios and has more abundantapplications. Therefore, this embodiment of this application resolvesthe technical problem in the related art that information carried in abar code is static and relatively simple.

The foregoing process of generating the target programmable bar code inresponse to the programmable bar code encoding request may include, butis not limited to, the following method: obtaining target code; andusing a target bar code encoding algorithm to obtain the targetprogrammable bar code with a character string of the target code as theinput parameter.

The target code may be obtained by using, but not limited to, thefollowing method: a corresponding target parameter value is obtainedaccording to a parameter input operation, for example, an identificationcard number of a ticket purchaser entered by a ticket seller; the targetparameter may be encrypted, and then the encrypted target parameter isencoded to obtain the target code. For example, the foregoingidentification card number is encrypted and then encoded to obtain thecorresponding target code to protect the identification card number.Furthermore, a logical function of a read permission to anidentification card number may be set in the target code, or a validityperiod for running the code may be set in the target code, so onlyentities with right permission may run the target code to retrieve theidentification information during the validity period.

The target code in this embodiment of this application is used forexecuting at least one of the following target logical functions:

(1) A target logical function, which may be used for allowing a targethaving a read permission to run the target code, where the target may bean account, a device or a virtual machine.

(2) A target logical function, which may be used for allowing the targetcode to be run within a validity period.

When the target code is used for executing the foregoing two targetlogical functions, the programmable bar code encoding request may beobtained by using, but not limited to the following method: generating,by the terminal in response to receiving a request for generating atarget programmable bar code corresponding to predetermined information(for example, identification card information) of a ticket, aprogrammable bar code encoding request carrying the predeterminedinformation according to the request. The generating a targetprogrammable bar code in response to the programmable bar code encodingrequest may be implemented by using, but not limited to the followingmethod: encoding, by the terminal, the target code including thepredetermined information to obtain the target programmable bar codeaccording to the foregoing programmable bar code encoding request.

(3) A target logical function, which may be used for calling targethardware to execute a target operation.

When the target code is used for executing the foregoing target logicalfunction, the programmable bar code encoding request may be obtained byusing, but not limited to the following method: receiving, by theterminal, a target request that is used for requesting to generate thetarget programmable bar code for target location positioning; andgenerating, by the terminal in response to the programmable bar codeencoding request, the programmable bar code. The programmable bar codeencoding request carrying an identifier of a target positioning hardware(for example, a GPS) in a target device. The target device may be anydevice or terminal which scans the generated programmable bar code torun the target code. The generating a target programmable bar code inresponse to the programmable bar code encoding request includes:encoding, by the terminal, target code used for identifying andconfiguring target hardware in the target device to obtain a targetprogrammable bar code, so that after the bar code is scanned, thecorresponding target code may be run to call the target hardware (forexample, the GPS) to position the target location.

The foregoing target programmable bar code may be directly displayed onthe terminal, or may be printed on a target medium. The foregoing targetmedium includes, but is not limited to the following: paper, cloth,plastic, glass, or the like.

In an optional solution, in this embodiment, the foregoing process ofgenerating a target programmable bar code in response to theprogrammable bar code encoding request may be implemented by using, butnot limited to the following method: obtaining target code; andexecuting a target bar code encoding algorithm to obtain the targetprogrammable bar code using a character string of the target code as aninput parameter.

Description is specifically made with reference to the followingexamples where a QR code is used. As shown in FIG. 3 , it is assumedthat the target code has been generated, for example, through compilingof source code, and the character string of the target code is encodedby using a QR code encoder on the terminal 302, to obtain acorresponding target programmable QR code. A target QR code encodingalgorithm may be installed in the foregoing QR code encoder, and thetarget QR code encoding algorithm may be an existing QR code encodingalgorithm. In one embodiment, the target code after the compilation maybe in binary code format. Optionally, the target code may be encryptedfirst before the encoding.

As compared with the related art, in this embodiment of thisapplication, the character string of the target code is used as theinput parameter of the target bar code encoding algorithm. Textinformation is no longer used as the input parameter of the bar codeencoding algorithm, and instead, the character string of the target codeis used as the input parameter of the bar code encoding algorithm.Therefore, the foregoing programmable bar code carries the target code,and the bar code does not carry plain text information but a piece ofcode, to avoid information leakage.

In an optional solution, in this embodiment, the foregoing target codeis obtained by using, but not limited to the following method: obtaininga target parameter value in response to a parameter input operation; andgenerating the target code according to the target parameter value, avalue of a parameter in the target code being the target parametervalue.

Description is specifically made with reference to the followingexample. As shown in FIG. 4 , a ticket seller enters identificationinformation of a ticket purchaser on a terminal 402, and a controlprogram editor sets a target parameter value of a target code modelstored on the terminal to the identification information (for example,an identification card number) to generate corresponding target code. Toreduce complexity of a QR code, the foregoing program editor may be, butis not limited to, an integrated development environment (IDE forshort). The foregoing target code model may be pre-compiled, and theticket seller only needs to enter the target parameter value. Thelogical function that the target code model may implement is notlimited. The logical function may be a permission of running the targetcode, or a validity period the target code may be run, or the logicalfunction may identify and configure a hardware on the target device.

Through the foregoing embodiment, the target parameter value may beobtained according to a parameter input operation (for example,identification information is inputted) received by the terminal; andthen, the target parameter is used as an input to the target code modelto generate the target code, so that a programmable bar code may beconveniently generated without a special requirement on the compilingcapability of a user who generates the bar code.

In an optional solution, the foregoing target code in this embodiment isused for executing at least one of the following target logicalfunctions:

(1) A first target logical function, used for allowing an account, adevice, or a virtual machine with a read permission to run the targetcode. A bar code read permission may be implemented to improve bar codesecurity.

For example, the foregoing embodiment may be applied to a ticket. Inthis case, description is made by using a train ticket as an example. Aread permission of a target programmable QR code is carried in targetcode of the QR code displayed on the train ticket, so that when the QRcode is scanned, even if the target code is decoded, the target code maynot necessarily be run; that is, only a device that has a readpermission and that is in the hands of a ticket inspector who has alegitimate account can run the target code to read the identificationcard information in the target programmable QR code, to determinewhether the passenger is the right person.

(2) A second target logical function, used for limiting the target codeto be run within a validity period. The validity period during which abar code may be read is limited by using the foregoing logical function,to improve bar code security.

For example, the foregoing embodiment may be further applied to aticket. In this case, description is made by using a scenic spot as anexample. Target code of a QR code displayed on the scenic spot ticketcarries a validity period of a target programmable QR code. For example,the ticket is valid on Mar. 22, 2018, so that when scanning the QR code,even if the target code is decoded, the target code may not necessarilybe run. Only on Mar. 22, 2018, the target code can be successfully run.

(3) A third target logical function, used for calling target hardware toexecute a target operation. Through the foregoing target logicalfunction, any hardware that is expected to be called may be identifiedand called by reading the bar code, so that the programmable bar codecan complete more complex logical functions by calling and engagingother hardware, for example, a GPS hardware for positioning the device.

In an optional solution, in this embodiment, the programmable bar codeencoding request is obtained by using, but not limited to the followingmethod: receiving, by a terminal, a target request that is used forgenerating a target programmable bar code corresponding to predeterminedinformation (for example, the foregoing identification card informationof a target ticket), and generating, by the terminal in response to therequest, a programmable bar code encoding request carrying thepredetermined information. The generating a target programmable bar codein response to the programmable bar code encoding request may beimplemented by using, but not limited to the following method: encoding,by the terminal, the target code to obtain the target programmable barcode, a parameter of the target code including the predeterminedinformation.

For example, the foregoing embodiment may be applied to a ticket (suchas a train ticket, a movie ticket, or an attraction ticket). Descriptionis made by using a train ticket as an example. Specific description ismade with reference to the following example, as shown in FIG. 5 . Atourist A needs to buy a train ticket to the place B, and the ticket maybe bought online or manually through a counter. In this embodiment,description is made by using an example in which a ticket is boughtmanually through a counter. After getting information such as A'sidentification card or the like, a ticket seller C enters theidentification number information of A in a terminal 502 to trigger theterminal to generate a programmable QR code encoding request, and addthe identification card number information of A to an request. Inresponse to the request, the terminal 502 adds the identification cardnumber information of A to target code, then a terminal 504 encodes thetarget code to obtain a target programmable QR code, and then the targetprogrammable QR code is printed on the train ticket. At last, A obtainsthe train ticket printed with the target programmable QR code. Theoperations executed by the terminal 502 and the terminal 504 may beexecuted on the same terminal, or two different terminals incommunication with each other.

In an optional solution, in this embodiment, the target code may befurther used for executing the following target logical function: afirst target logical function, used for allowing an account having aread permission to run the target code, or allowing a device having aread permission to run the target code, or allowing a virtual machinehaving a read permission to run the target code. For example, theforegoing target code may include a permission to read a targetprogrammable bar code, that is, only an account, a device, and the likehaving the foregoing permission can read the foregoing targetprogrammable bar code, such as the QR code on the train ticket.Therefore, even if the target code is decoded, only a device that has aread permission and that is in the hands of a ticket inspector who has alegitimate account can run the target code to read the identificationcard information in the target programmable QR code, to determinewhether the passenger is the right person.

In an optional solution, in this embodiment, the programmable bar codeencoding request is obtained by using, but not limited to the followingmethod: receiving, by a terminal, a target request that is used forgenerating a target programmable bar code which may be used to identifyand configure a target hardware, and generating, by the terminal inresponse to the request, a programmable bar code encoding requestcarrying an identifier of a target hardware (for example, the foregoingGPS) of the target device. Optionally, in this embodiment, thegenerating a target programmable bar code in response to theprogrammable bar code encoding request includes: encoding, by theterminal, the target code to obtain the target programmable bar code,the target code including a parameter used for identifying the targethardware in the terminal, and the target logical function being used forcalling the target hardware to position the target device location.

For example, the foregoing embodiment may be applied to locationpositioning. Description is made by using an example in which a GlobalPositioning System (GPS for short) in the target device is called toposition the target device. When a terminal receives a request that atarget programmable QR code for positioning the target location needs tobe generated, a programmable QR code encoding request including a GPSidentifier is generated, and the terminal is triggered to add theidentifier to the target code. The target code is then encoded to obtaina target programmable QR code. Subsequently, the target code may beretrieved by scanning the target programmable QR code using the targetdevice, and the target location may be positioned by running the targetcode which in turn calls the GPS hardware. In one embodiment, the targetcode embedded in the QR code printed on the ticket may further carry adesignated location. In this case, once the target location isidentified by executing the target code, the target location informationmay be further used to compare with the designated location carried inthe QR code to determine the validity of the ticket.

In an optional solution, in this embodiment, the displaying the targetprogrammable bar code includes at least one of the following:displaying, by the terminal, the target programmable bar code, andprinting, by the terminal, the target programmable bar code on a targetmedium. The displaying the target programmable bar code may be todisplay the target programmable bar code on the terminal directly, orprint the target programmable bar code on a target medium. The foregoingtarget medium includes but is not limited to the following: paper,cloth, plastic, glass, or the like.

Optionally, the foregoing embodiment may be further applied tocryptography. Previous cryptographic encryption results are all staticcharacters. The encryption results may be dynamically changed at anytime by using similar principles of the programmable QR codes asdescribed in this disclosure, and a permission of a reader may beauthenticated, providing a new solution for information security.

Optionally, the target code may be optimized to be as concise aspossible. In one embodiment, custom language rules for encoding targetcode may be, but are not limited to the following:

1. A variable definition may be similar to js (JavaScript) and there isno need to declare variable types; and all variables start with “v_”.

2. When an object is instantiated, a “new” keyword is not needed and(param, param . . . ) is added behind a class name directly. Forexample, v_obj=Object ( ).

3. Each line of code ends with “;”; and there is no need to change line.

4. Four arithmetic operations (+−*/) may be used for classes of whichoperation content is essentially numeric. For example, for a Date type,a time difference may be calculated by directly using “−” operation.

For example, sample code may be as shown in FIG. 6 . A validity periodis set for the code, and a time difference between a current time and2012-8-12 (only for the exemplary purpose) is calculated. If the timedifference is within 1 minute, the target code may be run and “valid” isprompted; otherwise, “invalid” is prompted.

According to another aspect of the embodiments of this application, abar code scanning method is further provided, and the method may beapplied to the environment shown in FIG. 1 . The bar code scanningmethod, as shown in FIG. 7 , may include:

S702: Scan a target programmable bar code to obtain target code, thetarget programmable bar code being a bar code obtained by encoding thetarget code, and the target code being used for executing a targetlogical function.

S704: Run the target code to execute the target logical function.

S706: Display a result obtained by executing the target logicalfunction.

The foregoing programmable bar code may be applied to a ticket (such asa train ticket, a movie ticket, or an attraction ticket). For example,personal information is carried in target code, and a bar code carryingthe target code is printed on the ticket. Upon scanning, the target codemay be decoded from the bar code and executed to retrieve the personalinformation. The programmable bar code may be further applied tolocation positioning. For example, the target code carries informationsuch as a hardware identifier for calling corresponding positioninghardware, and a bar code carrying the target code is printed on aticket, so that the positioning hardware may be called by scanning thebar code to position the device location. The foregoing description isonly two examples and this embodiment does not impose any limitation onthis.

A programmable bar code is obtained by encoding target code, that is,information carried in the programmable bar code is the target code.Because the target code implements logical judgments and algorithms, thetarget code may be run to implement various logical functions, andgreatly expand a range of information carried in a bar code, so that theprogrammable bar code is applicable to more complex scenarios and hasmore abundant applications. Therefore, this embodiment of thisapplication resolves the problem in the related art that informationcarried in a bar code is static and relatively simple.

The scanning a target programmable bar code to obtain target code may beimplemented by using, but not limited to the following method: inputtinga scanned target programmable bar code into a decoding algorithmcorresponding to the encoding algorithm, to decode the targetprogrammable bar code, and if the target code is encrypted in anencoding process, performing corresponding decryption after decoding toobtain the target code.

For example, the foregoing target code is used for executing at leastone of the following target logical functions:

(1) A target logical function, which may be used for allowing an accounthaving a read permission to run the target code, or allowing a devicehaving a read permission to run the target code, or allowing a virtualmachine having a read permission to run the target code.

For example, in a case that the target code is used for executing theforegoing target logical function, running the target code to executethe target logical function is implemented by using, but not limited tothe following method: running the target code, and determining whether atarget account that scans the target programmable bar code has a readpermission; and displaying a result obtained by executing the targetlogical function includes: executing the target logical functioncorresponding to the foregoing target code when it is determined thatthe target account has a read permission, and displaying a resultobtained by executing the target logical function.

(2) A target logical function, which may be used for allowing the targetcode to be run within a validity period.

For example, in a case that the target code is used for executing theforegoing target logical function, running the target code to executethe target logical function may be implemented by using, but not limitedto the following method: running the target code, and determiningwhether a target code is within the validity period; and the resultobtained by executing the target logical function may be displayed byusing, but not limited to the following method: displaying the resultobtained by executing the target logical function only after it isdetermined that the target code is within the validity period.

(3) A target logical function, which may be used for calling targethardware to execute a target operation.

For example, in a case that the target code is used for executing theforegoing target logical function, the running the target code toexecute the target logical function may be implemented by using, but notlimited to the following method: obtaining an identifier of the targethardware in a target device; and calling the target hardware indicatedby the identifier to execute the target operation.

For another example, the scanning a target programmable bar code toobtain target code may be implemented by using, but not limited to thefollowing method: scanning, by the terminal on a target medium, a targetprogrammable bar code carrying a parameter that identifies targethardware used for positioning a target location in the terminal, toobtain the target code. Optionally, the running the target code toexecute the target logical function may be implemented by using, but notlimited to the following method: obtaining, by the terminal, theidentifier of the target hardware according to the parameter thatidentifies the target hardware used for positioning the target locationin the terminal, and calling, by the terminal, the target hardwareindicated by the identifier to position the target location, and thendisplaying the positioned target location.

In an optional solution, in this embodiment, the scanning the targetprogrammable bar code to obtain target code may be implemented by using,but not limited to the following method: decoding a scanned targetprogrammable bar code by using a decoding algorithm corresponding to theencoding algorithm, to obtain the target code. As compared with therelated art, in this embodiment of this application, text information isnot obtained after decoding directly, but corresponding target code isobtained, so that corresponding information of the target code cannot beobtained if the target code is not permitted to run, for example, due tono read permission, or the target environment not supporting the targetcode, or not within the validity period, to avoid information leakage.

Description is specifically made with reference to the followingexample. As shown in FIG. 8 , the foregoing target programmable QR codeis decoded by using a QR code decoder on a terminal 802, to obtain thecorresponding target code. A target QR code decoding algorithm may beinstalled in the foregoing QR code decoder, and the target QR codedecoding algorithm may be an existing target QR code decoding algorithm.

In an optional solution, the foregoing target code in this embodiment isused for executing at least one of the following target logicalfunctions:

(1) A first target logical function, used for allowing an account havinga read permission to run the target code, or allowing a device having aread permission to run the target code, or allowing a virtual machinehaving a read permission to run the target code. A bar code readpermission may be limited by using the foregoing logical function, toimprove bar code security.

(2) A second target logical function, used for allowing the target codeto be run within a validity period. The validity period during which abar code may be read and the target code may be run is limited by usingthe foregoing logical function, to improve bar code security.

(3) A third target logical function, used for calling target hardware toexecute a target operation. Through the foregoing logical functions, anyhardware that is expected to be called may be called by reading the barcode, so that the programmable bar code can complete more complexlogical functions.

In an optional solution, in this embodiment, when the target code isused for executing the foregoing first target logical function, runningthe target code to execute the target logical function may beimplemented by using, but not limited to the following method: runningthe target code, and determining whether the target account has a readpermission, the target account being used for scanning the targetprogrammable bar code; and displaying a result obtained by executing thetarget logical function may be implemented by using, but not limited tothe following method: displaying the result obtained by executing thetarget logical function when it is determined that the target accounthas a read permission. Through the foregoing embodiment, a bar code readpermission mechanism is implemented, and security of a bar code isimproved.

For example, the foregoing embodiment may be applied to a ticket (suchas a train ticket, a movie ticket, or an attraction ticket). Descriptionis made still by using a train ticket as an example. Description isspecifically made with reference to the following example, as shown inFIG. 5 . When a passenger A's train ticket is checked, the ticketinspector uses the device in the hands to scan the QR code on the trainticket, to obtain the target code embedded in the QR code. Because thedevice in the hands of the ticket inspector has a permission to read theforegoing QR code, A's identification card information may be obtainedby successfully running the target code. On the other hand, unauthorizeddevice or person may not be able to read the bar code.

In an optional solution, in this embodiment, in a case that the targetcode is used for executing the foregoing first target logical function,running the target code to execute the target logical function may beimplemented by using, but not limited to the following method: runningthe target code, and determining whether a target programmable bar codeis within the validity period; and the result obtained by executing thetarget logical function may be displayed by using, but not limited tothe following method: displaying the result obtained by executing thetarget logical function after it is determined that the targetprogrammable bar code is within the validity period. Through theforegoing embodiment, the bar code is valid within a validity period,and bar code security and flexibility is improved.

In an optional solution, in this embodiment, in a case that the targetcode is used for executing the foregoing first target logical function,the running the target code to execute the target logical function maybe implemented by using, but not limited to the following method:obtaining an identifier of the target hardware in a target device; andcalling the target hardware indicated by the identifier to execute thetarget operation. Through the foregoing embodiment, the target hardwaremay be called and engaged through the bar code, so that the bar code isapplicable to more complex scenarios and has more abundant applications.

For example, the foregoing embodiment may be applied to locationpositioning. When the foregoing embodiment is applied to locationpositioning, description is made still by using an example in which theGPS in the terminal is called for location positioning. The terminalscans the target programmable QR code, to obtain the target codeincluding the GPS identifier. The terminal runs the target code, callsand configures the GPS corresponding to the identifier to obtain theposition information of the target location (that is, the currentposition), and then displays the information on the terminal. It is tobe further understood, the target hardware may be any kind of hardwaredevices or components, or the like in the terminal (target device).

In an optional solution, in this embodiment, the scanning a targetprogrammable bar code to obtain target code may be implemented by using,but not limited to the following method: scanning, by the terminal, atarget programmable bar code on a target medium to obtain the targetcode, the target programmable bar code carrying a parameter foridentifying the target hardware in the terminal and being used forpositioning the target location. Optionally, in this embodiment, therunning the target code to execute the target logical function may beimplemented by using, but not limited to the following method:obtaining, by the terminal, the identifier of the target hardwareaccording to the foregoing parameter; and calling, by the terminal, thetarget hardware indicated by the identifier to position the targetlocation. Optionally, in this embodiment, the result obtained byexecuting the target logical function may be displayed by using, but notlimited to the following method: displaying, by the terminal, the targetlocation.

Optionally, the foregoing embodiment may be further applied tocryptography. Previous cryptographic encryption results are all staticcharacters. The encryption results may be dynamically changed at anytime by using similarity principles of programmable QR codes, and apermission of a reader may be authenticated, providing a new solutionfor information security.

In an optional solution, the running the target code to execute thetarget logical function may be implemented by using, but not limited tothe following method: calling a predetermined virtual machine, thepredetermined virtual machine being configured to run the target code;and running the target code on the predetermined virtual machine, toexecute the target logical function. In this embodiment, the foregoingtarget code may be directly run on a virtual machine, or the virtualmachine may be called through an application on the terminal, to run thetarget code on the virtual machine. The virtual machine may becustomized and proprietary, or non-proprietary.

The foregoing target code may be an executable program that runsdirectly on a virtual machine, or may be code written through theintegrated software development environment (IDE) to reduce the QR codecapacity and complexity requirement, the tool for writing the code isnot limited to the IDE.

When written through the integrated software development environmentIDE, the target code needs to be converted into general front-end code(for example, js code) by a virtual machine in a decoding process.

To facilitate understanding of the foregoing embodiments, in thisembodiment, description is made still by using an example in which thebar code is a QR code with reference to encoding and decoding of theprogrammable QR code.

As shown in FIG. 9 , in this embodiment of this application, the targetcode carrying original text is written through the IDE first to obtainthe source code or the binary code (also referred to as byte code inthis disclosure) as shown in FIG. 6 . The programmable QR code is thenobtained by encoding the target code by using a QR code encoder. Thetarget code is then retrieved by decoding the programmable QR code byusing a QR code decoder. At last, the original text is obtained byrunning the target code through the virtual machine. Specifically, anexemplary encoding and decoding process of a programmable QR code is asfollows:

During encoding, the code including the original text is written throughthe IDE to generate the source code or the binary code. Generatedcharacter strings are used as parameters, and a QR code graphic isgenerated by using the existing QR code encoding algorithm.

During decoding and reading, information content is restored throughimage recognition and a decoding algorithm, that is, the source code orthe binary code is retrieved by using the existing QR code decodingalgorithm. The original text is obtained by executing the retrieved codeon a dedicated virtual machine.

Detailed description of encoding and decoding of a programmable QR codeis made below by using an example in which a QR code validity period isset.

(1) Target code is written through the integrated developmentenvironment IDE, the code shown in FIG. 6 being used as an example ofthe target code.

(2) The QR code is generated by encoding, that is, character strings ofthe target code in step (1) may be converted into a QR code by using theexisting QR code encoding technologies, as shown in FIG. 10 .

(3) The QR code is decoded, the virtual machine software development kit(SDK) may be integrated on a mobile terminal (android/ios) platform, andthe code character strings are restored (that is, the target code) afterscanning. The dedicated virtual machine is called and the target code isconverted into general js code. For example, the target code shown inFIG. 6 is converted into the general js code shown in FIG. 11 .Alternatively, the target code may be executable binary code that may berun directly in the target environment without conversion.

(4) The target code is run, and the code may be executed by using anexecutor method of the virtual machine, to complete logic in the targetcode. The foregoing virtual machine may further support conversionbetween multiple programming languages to make the converted target codesuitable to be run in the target environment.

Content of the programmable QR code in this embodiment of thisapplication is no longer static text information, but binary codegenerated by a programming language and the corresponding compiler, orthe source code itself. During bar code scanning from a target device,the content obtained by using the existing QR code decoding technologiesis not text but target code which may be binary or source code.Information that a QR code expects to convey can be obtained only byrunning the retrieved target code in a predetermined target environmentwhich is configured to support the target code. In this way, as comparedwith the previous QR code technologies, a read permission and a validityperiod may be implemented in the target code, and even hardware in thetarget device may be called and configured, to complete other morecomplex logic. Therefore, the programmable QR code of this embodiment ofthis application greatly expands capability of a QR code, so that astatic QR code has its own programming logic, and the QR code isapplicable to more complex scenarios and has more abundant applications.As compared with the existing QR code solutions, the programmable QRcode is more secure, more expandable, and has more prospects for use.Furthermore, the quantity of code bytes may be compressed by customizinga special QR code programming language to improve the executionefficiency of encoding and decoding.

Similar to ideas of dynamic QR codes, there will be similar applicationsin cryptography, and this helps improve current encryption security.

Optionally, in this embodiment, the foregoing terminal may include, butis not limited to, at least one of the following: a mobile phone, atablet computer or the like.

For ease of description, the foregoing method embodiments are stated asa series of action combinations. However, a person skilled in the artneeds to learn that this application is not limited to the describedsequence of the actions because according to this application, somesteps may use another sequence or may be simultaneously performed. Inaddition, it is to be understood by a person skilled in the art that theembodiments described in this specification are all preferredembodiments, and the actions and modules in the embodiments are notmandatory for this application.

Through the descriptions of the foregoing implementations, a personskilled in the art may clearly understand that the method according tothe foregoing embodiments may be implemented by means of software and anecessary general hardware platform, and certainly, may also beimplemented by hardware, but in many cases, the former manner is abetter implementation. Based on such an understanding, the technicalsolutions of this application essentially, or the part contributing tothe related art may be implemented in a form of a software product. Thecomputer software product is stored in a storage medium (for example, aROM/RAM, a magnetic disk, or an optical disc), and includes severalinstructions for instructing a terminal device (which may be a mobilephone, a computer, a server, a network device, or the like) to performthe methods according to the embodiments of this application.

According to another aspect of the embodiments of this application, abar code display apparatus is further provided. As shown in FIG. 12 ,the apparatus includes:

an obtaining unit 1202, configured to obtain a programmable bar codeencoding request;

a generating unit 1204, configured to generate a target programmable barcode in response to the programmable bar code encoding request, thetarget programmable bar code being a bar code obtained by encoding thetarget code, and the target code being used for executing a targetlogical function; and

a display unit 1206, configured to display the target programmable barcode.

The foregoing programmable bar code may be applied to a ticket (such asa train ticket, a movie ticket, or an attraction ticket). For example,personal information on a ticket is carried in target code, and then abar code carrying the target code is printed on the ticket, so thatcontent carried in the bar code may be the target code comprising thepersonal information. The programmable bar code may be further appliedto location positioning. For example, the target code carriesinformation for calling corresponding positioning hardware, and then abar code carrying the target code is printed on a ticket, so that thepositioning hardware may be called by scanning the bar code to positionthe location, and content carried in the bar code may be the target codecomprising the information for calling the corresponding positioninghardware. The foregoing description is only two examples and thisembodiment does not impose any limitation on this.

A displayed programmable bar code is obtained by encoding the targetcode, that is, information carried in the programmable bar code is thetarget code. Because the target code has logical judgments andalgorithms, the target code can implement various logical functions, andgreatly expand a range of information carried in a bar code, so that theprogrammable bar code is applicable to more complex scenarios and hasmore abundant applications. Therefore, this embodiment of thisapplication resolves the technical problem in the related art thatinformation carried in a bar code is relatively simple.

In an optional implementation solution, a second obtaining unit 704includes:

an obtaining module, configured to obtain target code; and

an execution module, configured to obtain the target programmable barcode by executing a target bar code encoding algorithm, a characterstring of the target code being used as an input parameter to the targetbar code encoding algorithm.

Description is specifically made with reference to the followingexamples. As shown in FIG. 3 , it is assumed that the target code hasbeen written, the character string of the target code is encoded byusing a QR code encoder on the terminal 302 to obtain a correspondingtarget programmable QR code. A target QR code encoding algorithm may beinstalled in the foregoing QR code encoder, and the target QR codeencoding algorithm may be an existing QR code encoding algorithm.

As compared with the related art, in this embodiment of thisapplication, text information is no longer used as the input parameterof the QR code encoding algorithm, and instead, the character string ofthe target code is used as the input parameter of the QR code encodingalgorithm. Furthermore, the character string may be encrypted before theencoding. Therefore, the foregoing programmable QR code carries thetarget code, so that the QR code does not carry information but a pieceof code, to avoid information leakage.

Optionally, the foregoing target code in this embodiment is used forexecuting at least one of the following target logical functions:

(1) A first target logical function, used for allowing an account havinga read permission to run the target code, or allowing a device having aread permission to run the target code, or allowing a virtual machinehaving a read permission to run the target code. A bar code readpermission may be limited by using the foregoing target logicalfunction, to improve bar code security.

(2) A second target logical function, used for allowing the target codeto be run within a validity period. The validity period during which abar code may be read is limited by using the foregoing target logicalfunction, to improve bar code security.

(3) A third target logical function, used for calling target hardware toexecute a target operation. Through the foregoing target logicalfunction, any hardware that is expected to be called may be called byreading the bar code, so that the programmable bar code can completemore complex functions.

Optionally, in this embodiment, the programmable bar code encodingrequest is obtained by using, but not limited to the following method:receiving, by a terminal, a target request that is used for generating atarget programmable bar code corresponding to predetermined information(for example, the foregoing identification card information) of a targetticket, and generating, by the terminal in response to the request, aprogrammable bar code encoding request carrying the predeterminedinformation. The generating a target programmable bar code in responseto the programmable bar code encoding request may be implemented byusing, but not limited to the following method: encoding, by theterminal, the target code to obtain the target programmable bar code, aparameter of the target code including the predetermined information.

Optionally, in this embodiment, the target code is further used forexecuting the following target logical function: a first target logicalfunction, used for allowing an account having a read permission to runthe target code, or allowing a device having a read permission to runthe target code, or allowing a virtual machine having a read permissionto run the target code. For example, the foregoing target code mayinclude a permission to read a target programmable bar code, that is,only an account, a device, and the like having the foregoing permissioncan read the foregoing target programmable bar code, such as the QR codeon the train ticket. Even if the target code is decoded, only a devicethat has a read permission and that is in the hands of a ticketinspector can run the target code to read the identification cardinformation in the target programmable QR code, to determine whether thepassenger is the right person.

Optionally, in this embodiment, the programmable bar code encodingrequest is obtained by using, but not limited to the following method:receiving, by a terminal, a target request that is used for requestingto generate the target programmable bar code for target locationpositioning, and generating, by the terminal in response to the request,a programmable bar code encoding request carrying an identifier of atarget positioning hardware (for example, the foregoing GPS) in thetarget device. Optionally, in this embodiment, the generating a targetprogrammable bar code in response to the programmable bar code encodingrequest includes: encoding, by the terminal, the target code to obtainthe target programmable bar code, the target code including a parameterused for identifying the target hardware in the target device, so thatafter the bar code is read, the corresponding target code may be run tocall and configure the target hardware (for example, the GPS) toposition the target location.

Optionally, in this embodiment, the displaying the target programmablebar code includes at least one of the following: displaying, by theterminal, the target programmable bar code, and printing, by theterminal, the target programmable bar code on a target medium. Thedisplaying the target programmable bar code may be to display the targetprogrammable bar code on the terminal directly, or print the targetprogrammable bar code on a target medium. The foregoing target mediumincludes but is not limited to the following: paper, cloth, plastic,glass, or the like.

According to another aspect of the embodiments of this application, abar code scanning apparatus is further provided. As shown in FIG. 13 ,the apparatus includes:

a scanning unit 1302, configured to scan a target programmable bar codeto obtain the target code, the target programmable bar code being a barcode obtained by encoding the target code, and the target code beingused for executing the target logical function;

a running unit 1304, configured to run the target code to execute thetarget logical function; and

a display unit 1306, configured to display a result obtained byexecuting the target logical function.

The foregoing programmable bar code may be applied to a ticket (such asa train ticket, a movie ticket, or an attraction ticket). For example,personal information on a ticket is carried in target code, and then abar code carrying the target code is printed on the ticket. Uponscanning, the target code may be decoded from the bar code and executedto retrieve the personal information. The programmable bar code may befurther applied to location positioning. For example, the target codecarries information such as a hardware identifier for callingcorresponding positioning hardware, and then a bar code carrying thetarget code is printed on a ticket, so that the positioning hardware maybe called by scanning the bar code to position the device location. Theforegoing description is only two examples and this embodiment does notimpose any limitation on this. Furthermore, the hardware identifier maybe used to identify any hardware.

A programmable bar code is obtained by encoding target code, that is,information carried in the programmable bar code is the target code.Because the target code implements logical judgments and algorithms, thetarget code may be run to implement various logical functions, andgreatly expand a range of information carried in a bar code, so that theprogrammable bar code is applicable to more complex scenarios and hasmore abundant applications. Therefore, this embodiment of thisapplication resolves the problem in the related art that informationcarried in a bar code is static and relatively simple.

In an optional solution, a scanning unit 802 includes:

a decoding module, configured to decode the scanned target programmablebar code by using a decoding algorithm corresponding to an encodingalgorithm, to obtain the target code.

For example, the scanning a target programmable bar code to obtaintarget code may be implemented by using, but not limited to thefollowing method: inputting a scanned target programmable bar code intoa decoding algorithm corresponding to an encoding algorithm, anddecoding the target programmable bar code to obtain the target code.

For example, the foregoing target code is used for executing at leastone of the following target logical functions:

(1) A target logical function, which may be used for allowing an accounthaving a read permission to run the target code, or allowing a devicehaving a read permission to run the target code, or allowing a virtualmachine having a read permission to run the target code.

(2) A target logical function, which may be used for allowing the targetcode to be run within a validity period.

(3) A target logical function, which may be used for calling targethardware to execute a target operation.

Optionally, in this embodiment, the scanning unit 802 is further usedin, but not limited to the following method: scanning, by the terminal,a target programmable bar code on a target medium to obtain the targetcode, the target programmable bar code carrying a parameter foridentifying the target hardware used for positioning the target locationin the terminal.

Optionally, in this embodiment, a running unit 804 is further configuredto, but is not limited to the following method: obtaining, by theterminal, the identifier of the target hardware according to theforegoing parameter; and calling, by the terminal, target hardwareindicated by the identifier to position the target location.

Optionally, in this embodiment, a display unit 806 is further used in,but not limited to the following method: displaying, by the terminal,the target location.

In this embodiment, the foregoing target code may be directly run on avirtual machine, or the virtual machine may be called through anapplication on the terminal, to run the target code on the virtualmachine. Optionally, the running the target code to execute the targetlogical function may be implemented by using, but not limited to thefollowing method: calling a predetermined virtual machine, thepredetermined virtual machine being configured to run the target code;and running the target code on the predetermined virtual machine toexecute the target logical function.

The foregoing target code may be a program that runs directly on avirtual machine, or may be code written through the integrated softwaredevelopment environment IDE to reduce carrying capacity of the QR code,but a tool for writing the code is not limited to the IDE.

In one embodiment, the target code is developed using the integrateddevelopment environment IDE, and may need to be converted into generalfront-end code (for example, js code) by a virtual machine in a decodingprocess before the target code may be executed.

According to still another aspect of the embodiments of thisapplication, a storage medium is further provided. The storage mediumstores a computer program, the computer program being configured toperform, during running, the steps in any one of the foregoing methodembodiments.

Optionally, in this embodiment, a person of ordinary skill in the artmay understand that all or some of the steps of the methods in theforegoing embodiments may be implemented by a program by instructinghardware relevant to a terminal device. The program may be stored in acomputer-readable storage medium, and the storage medium may include: aflash drive, a read-only memory (ROM), a random access memory (RAM), amagnetic disk, an optical disc, or the like.

According to still another aspect of the embodiments of thisapplication, an electronic device configured to implement the foregoingprogrammable bar code display and scanning methods is further provided.As shown in FIG. 14 , the electronic device includes a processor 1402and a memory 1404. Optionally, the foregoing electronic device mayfurther include: a display 1406, a user interface 1408, a transmissionapparatus 1410, a sensor 1412, and the like. The memory stores acomputer program. The processor is configured to perform the steps inany one of the foregoing method embodiments through the computerprogram.

Optionally, a person of ordinary skill in the art may understand that,the structure shown in FIG. 14 is only illustrative. The electronicdevice may alternatively be a terminal device such as a smartphone (forexample, an Android mobile phone or an iOS mobile phone), a tabletcomputer, a palmtop computer, a mobile Internet device (MID), or a PAD.FIG. 14 does not constitute a limitation on the structure of theforegoing electronic device. For example, the electronic device mayfurther include more or fewer components (for example, a networkinterface, or the like) than those shown in FIG. 14 , or haveconfiguration different from that shown in FIG. 14 .

The memory 1404 may be configured to store a software program and amodule, for example, a program instruction/module corresponding to thebar code generating, scanning, and display method and the bar codegenerating, scanning, and display apparatus in the embodiments of thisapplication, and the processor 1402 executes various functionalapplications and data processing, that is, implements the bar codedisplay and scanning method by running the software program and themodule stored in the memory 1404. The memory 1404 may include ahigh-speed random memory, and a non-volatile memory such as one or moremagnetic storage devices, a flash, or another non-volatile solid-statememory. In some embodiments, the memory 1404 may further includememories remotely disposed relative to the processor 1402, and theseremote memories may be connected to a terminal through a network. Anexample of the foregoing network includes, but is not limited to, theInternet, an intranet, a local area network, a mobile communicationsnetwork, or a combination thereof.

The foregoing transmission apparatus 1410 is configured to receive orsend data through a network. Specific examples of the foregoing networkmay include a wired network and a wireless network. In an example, thetransmission apparatus 1410 includes a network interface adapter (NIC)that may be connected to other network devices and routers through anetwork cable to communicate with the Internet or a local area network.In an example, the transmission apparatus 1410 is a radio frequency (RF)module, which is configured to communicate with the Internet in awireless manner.

The foregoing sensor 1412 is configured to collect real environment dataat a current real position of the terminal, the real environment dataincluding meteorological data, geographical data, and the like. Theforegoing display 1406 displays a programmable QR code. The userinterface 1408 is configured to obtain an input operation instruction,such as a programmable QR code encoding request, a target request, orthe like.

The sequence numbers of the foregoing embodiments of this applicationare merely for description purpose, and do not indicate the preferenceamong the embodiments.

In a case that the integrated unit in the foregoing embodiments isimplemented in the form of a software functional unit and sold or usedas an independent product, the integrated unit may be stored in theforegoing computer-readable storage medium. Based on such understanding,the technical solutions in this application essentially, or the partcontributing to the related technology, or all or some of the technicalsolutions may be implemented in a form of a software product. Thecomputer software product is stored in a storage medium and includesseveral instructions for instructing one or more computer devices (whichmay be a personal computer, a server, a network device, or the like) toperform all or some of steps of the methods in the embodiments of thisapplication.

In the foregoing embodiments of this application, the descriptions ofthe embodiments have their respective focuses. For a part that is notdescribed in detail in an embodiment, reference may be made to relateddescriptions in other embodiments.

In the several embodiments provided in this application, it is to beunderstood that the disclosed client may be implemented in othermanners. The described apparatus embodiment is merely an example. Forexample, the unit division is merely logical function division and maybe another division in an actual implementation. For example, aplurality of units or components may be combined or integrated intoanother system, or some features may be ignored or not executed. Inaddition, the coupling, or direct coupling, or communication connectionbetween the displayed or discussed components may be the indirectcoupling or communication connection by means of some interfaces, units,or modules, and may be in electrical or other forms.

The units described as separate parts may or may not be physicallyseparate, and the parts displayed as units may or may not be physicalunits, may be located in one position, or may be distributed on multiplenetwork units. A part of or all of the units may be selected accordingto actual needs to achieve the objectives of the solutions of theembodiments.

In addition, functional units in the embodiments of this application maybe integrated into one processing unit, or each of the units may existalone physically, or two or more units may be integrated into one unit.The foregoing integrated unit may be implemented in the form ofhardware, or may be implemented in the form of a software function unit.

The foregoing descriptions are merely exemplary implementations of thisapplication. A person of ordinary skill in the art may make improvementsand modifications without departing from the principle of thisapplication, and all such improvements and modifications fall within theprotection scope of this application.

What is claimed is:
 1. A method for bar code generation performed by adevice, the method comprising: obtaining a target code by compiling asource code, the target code being self-contained executable codecomprising target computer readable instructions and comprising logicfunctions, wherein the target computer readable instructions areexecutable by a processor; compressing code bytes of the target code toobtain a compressed target code; and generating a target bar codeembedded with the compressed target code by encoding the compressedtarget code, wherein the target code comprises at least one of thefollowing logical functions: a first logical function for allowing ascanning device with a read permission to run the target code, a secondlogical function for allowing the target code to be run within avalidity period, and a third logical function for calling andconfiguring target hardware in the scanning device to execute a targetoperation.
 2. The method of claim 1, wherein: before generating thetarget bar code embedded with the target code by encoding the targetcode, the method further comprises: encrypting the target code to obtainan encrypted target code; and generating the target bar code embeddedwith the target code by encoding the target code comprise: generatingthe target bar code embedded with the encrypted target code by encodingthe encrypted target code.
 3. The method of claim 1, wherein when thetarget bar code is scanned by the scanning device, a scanning operationcauses the scanning device to decode the target bar code to obtain thetarget code embedded in the target bar code, the scanning operationfurther causes the scanning device to execute the target code.
 4. Themethod of claim 3, wherein: the target code comprises a designatedlocation used for access control, and identification information of atarget hardware; the target hardware comprises a location positioninghardware; when the scanning device execute the target code, the scanningdevice is configured to: call the location positioning hardware toobtain a current location of the scanning device; compare the currentlocation with a designated location carried in the target bar code; anddetermine access is allowed in response to the current location matchingwith the designated location.
 5. The method of claim 1, wherein: thesource code is programmed using a first type programming language; andin response to a virtual machine in the scanning device having a readpermission to run the target code, the scanning device executes thetarget code via the virtual machine.
 6. The method of claim 1, wherein:the source code is programmed using a first type programming languageand the target code is compiled with a compiler for the first typeprogramming language; and a virtual machine in the scanning deviceexecutes the target code by: converting the target code based on asecond type programming language which is suitable to run in the virtualmachine, to obtain a converted target code; and executing the convertedtarget code.
 7. A device for bar code generation, comprising a memoryfor storing computer instructions and a processor in communication withthe memory, wherein, when the processor executes the computerinstructions, the processor is configured to cause the device to: obtaina target code by compiling a source code, the target code beingself-contained executable code comprising target computer readableinstructions and comprising logic functions, wherein the target computerreadable instructions are executable by a processor; compress code bytesof the target code to obtain a compressed target code; and generate atarget bar code embedded with the compressed target code by encoding thecompressed target code, wherein the target code comprises at least oneof the following logical functions: a first logical function forallowing a scanning device with a read permission to run the targetcode, a second logical function for allowing the target code to be runwithin a validity period, and a third logical function for calling andconfiguring target hardware in the scanning device to execute a targetoperation.
 8. The device of claim 7, wherein: before the processor isconfigured to cause the device to generate the target bar code embeddedwith the target code by encoding the target code, the processor isfurther configured to cause the device to: encrypt the target code toobtain an encrypted target code; and when the processor is configured tocause the device to generate the target bar code embedded with thetarget code by encoding the target code, the processor is configured tocause the device to: generate the target bar code embedded with theencrypted target code by encoding the encrypted target code.
 9. Thedevice of claim 7, wherein when the target bar code is scanned by thescanning device, a scanning operation causes the scanning device todecode the target bar code to obtain the target code embedded in thetarget bar code, the scanning operation further causes the scanningdevice to execute the target code.
 10. The device of claim 9, wherein:the target code comprises a designated location used for access control,and identification information of a target hardware; the target hardwarecomprises a location positioning hardware; when the scanning deviceexecute the target code, the scanning device is configured to: call thelocation positioning hardware to obtain a current location of thescanning device; compare the current location with a designated locationcarried in the target bar code; and determine access is allowed inresponse to the current location matching with the designated location.11. The device of claim 7, wherein: the source code is programmed usinga first type programming language; and in response to a virtual machinein the scanning device having a read permission to run the target code,the scanning device executes the target code via the virtual machine.12. The device of claim 7, wherein: the source code is programmed usinga first type programming language and the target code is compiled with acompiler for the first type programming language; and a virtual machinein the scanning device executes the target code by: converting thetarget code based on a second type programming language which issuitable to run in the virtual machine, to obtain a converted targetcode; and executing the converted target code.
 13. A non-transitorystorage medium for storing computer readable instructions, the computerreadable instructions, when executed by a processor in a device, causingthe processor to: obtain a target code by compiling a source code, thetarget code being self-contained executable code comprising targetcomputer readable instructions and comprising logic functions, whereinthe target computer readable instructions are executable by a processor;compress code bytes of the target code to obtain a compressed targetcode; and generate a target bar code embedded with the compressed targetcode by encoding the compressed target code, wherein the target codecomprises at least one of the following logical functions: a firstlogical function for allowing a scanning device with a read permissionto run the target code, a second logical function for allowing thetarget code to be run within a validity period, and third logicalfunction for calling and configuring target hardware in the scanningdevice to execute a target operation.
 14. The non-transitory storagemedium of claim 13, wherein: before the computer readable instructionscause the processor to generate the target bar code embedded with thetarget code by encoding the target code, the computer readableinstructions further cause the processor to: encrypt the target code toobtain an encrypted target code; and when the computer readableinstructions cause the processor to generate the target bar codeembedded with the target code by encoding the target code, the computerreadable instructions cause the processor to: generate the target barcode embedded with the encrypted target code by encoding the encryptedtarget code.
 15. The non-transitory storage medium of claim 13, whereinwhen the target bar code is scanned by the scanning device, a scanningoperation causes the scanning device to decode the target bar code toobtain the target code embedded in the target bar code, the scanningoperation further causes the scanning device to execute the target code.16. The non-transitory storage medium of claim 15, wherein: the targetcode comprises a designated location used for access control, andidentification information of a target hardware; the target hardwarecomprises a location positioning hardware; when the scanning deviceexecute the target code, the scanning device is configured to: call thelocation positioning hardware to obtain a current location of thescanning device; compare the current location with a designated locationcarried in the target bar code; and determine access is allowed inresponse to the current location matching with the designated location.17. The non-transitory storage medium of claim 13, wherein: the sourcecode is programmed using a first type programming language and thetarget code is compiled with a compiler for the first type programminglanguage; and a virtual machine in the scanning device executes thetarget code by: converting the target code based on a second typeprogramming language which is suitable to run in the virtual machine, toobtain a converted target code; and executing the converted target code.